<template>
  <div class="lantern">
    <span class="head-line"></span>
    <div class="center">
      <div class="center-line">
        <span>{{ str }}</span>
      </div>
      <span class="footer-line"></span>
    </div>
  </div>
</template>

<script setup lang="ts">
// 模块引入
//import { ref } from 'vue'
defineOptions({
  // 灯笼组件名称
  name: 'Lantern',
  // 继承透传，是否继承没在子组件声明的父组件的属性
  inheritAttrs: true
})

defineProps({
  str: {
    type: String,
    default: '春节快乐'
  }
})
</script>

<style scoped lang="scss">
.lantern {
  --lineColor: #ecaa2f;
  --bg: #f00;
  width: 200px;
  height: 150px;
  //   position: relative;
  animation: swing 3s infinite ease-in-out;
  .center {
    position: relative;
    width: 100%;
    height: 100%;
    background: var(--bg);
    border-radius: 120px;
    box-shadow: 0 0 80px -10px var(--bg);
    transform-origin: top center;
    animation: swing 3s infinite ease-in-out;
    border: 2px solid var(--lineColor);
    &::before,
    &::after {
      content: '';
      position: absolute;
      width: 80px;
      height: 10px;
      left: calc(50% - 40px);
      background: var(--lineColor);
      z-index: 2;
    }
    &::before {
      top: -8px;
      border-radius: 5px 5px 0 0;
    }
    &::after {
      bottom: -8px;
      border-radius: 0 0 5px 5px;
    }
    .center-line {
      width: 100%;
      height: 100%;
      &::before,
      &::after {
        content: '';
        position: absolute;
        top: 0;
        height: 150px;
        border-radius: 50%;
        border: 2px solid var(--lineColor);
      }
      &::before {
        width: 150px;
        left: calc(50% - 75px);
      }
      &::after {
        left: calc(50% - 35px);
        width: 70px;
      }
      span {
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: 18px;
        font-size: 18px;
        color: var(--lineColor);
        font-weight: bold;
      }
    }
  }
  .head-line {
    position: absolute;
    left: calc(50% - 2px);
    top: -60px;
    width: 4px;
    height: 60px;
    background-color: var(--lineColor);
    transform-origin: top center;
    // animation: swing 3s infinite ease-in-out 1.2s;
  }
  .footer-line {
    position: absolute;
    left: calc(50% - 2px);
    bottom: -50px;
    width: 4px;
    height: 50px;
    background: var(--lineColor);
    animation: swing 3s infinite ease-in-out;
    &::after {
      content: '';
      position: absolute;
      bottom: -75px;
      left: calc(50% - 8px);
      width: 16px;
      height: 80px;
      background: linear-gradient(
        #f00,
        #e35d00 3px,
        #fbd342 5px,
        #e36d00 8px,
        #e36d00 12px,
        rgba(255, 0, 0, 0.8) 26px,
        rgba(255, 0, 0, 0.6)
      );
      border-radius: 5px 5px 0 0;
    }
  }
}
@keyframes swing {
  0%,
  100% {
    transform: rotate(10deg);
  }
  50% {
    transform: rotate(-10deg);
  }
}
</style>
